package net.pinnoocle.playdao.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.pinnoocle.playdao.entity.Master;
import net.pinnoocle.playdao.entity.MasterScript;
import net.pinnoocle.playdao.entity.shopPc.BaseShopSearch;
import net.pinnoocle.playdao.entity.shopPc.master.CheckMasterListPageVo;
import net.pinnoocle.playdao.entity.shopPc.master.MasterListPageVo;
import net.pinnoocle.playdao.entity.shopPc.master.MasterListSearchParams;
import net.pinnoocle.playdao.entity.shopPc.master.WaitCheckMasterSearchParams;
import net.pinnoocle.playdao.entity.web.master.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 主持人(Master)表数据库访问层
 *
 * @author ye
 * @since 2021-10-22 17:19:45
 */
@Mapper
public interface MasterDao extends BaseMapper<Master> {

    /**
     * 店铺端主持人列表
     * @param page
     * @param params
     * @return
     */
    Page<MasterListPageVo> shopMasterListWithPage(Page page, @Param("params")MasterListSearchParams params);

    /**
     * web端主持人列表
     * @param page
     * @param shopId
     * @return
     */
    Page<WebMasterListPageVo> webMasterList(Page page, @Param("shopId")String shopId);

    /**
     * 门店DM待审核
     * @param page
     * @param params
     * @return
     */
    Page<CheckMasterListPageVo> shopWaitCheckMasterList(Page page, @Param("params") WaitCheckMasterSearchParams params);

    /**
     * 主持人会的剧本列表
     * @param page
     * @param masterId
     * @return
     */
    Page<WebMasterScriptListPage> masterScriptList(Page page,@Param("masterId") String masterId);

    /**
     * 审核DM
     * @param masterId
     * @return
     */
    boolean shopCheckPass(@Param("masterId") String masterId,
                          @Param("check") Integer check,
                          @Param("randomNumber") String randomNumber);

    /**
     * 批量删除主持人会的本
     * @param masterId
     * @return
     */
    boolean batchDeleteMasterScript(@Param("masterId") String masterId);

    /**
     * 更新主持人累计收益
     * @param masterId
     * @param amount
     * @return
     */
    boolean updateTotalAmount(@Param("masterId") String masterId,
                              @Param("amount") Double amount);

    /**
     * 主持人组局管理
     * @param masterId
     * @param startTime
     * @param endTime
     * @return
     */
    List<MasterGroupListVo> myGroupList(@Param("masterId") String masterId,
                                        @Param("startTime") String startTime,
                                        @Param("endTime") String endTime);

    /**
     * 咨询师id
     * @param masterId
     * @return
     */
    BigDecimal getMasterBalance(@Param("masterId") String masterId);

    /**
     * 获取本月玩家数、场次
     * @param masterId
     * @param startTime
     * @param endTime
     * @return
     */
    MasterFinanceVo getMonthReport(@Param("masterId") String masterId,
                                   @Param("startTime") String startTime,
                                   @Param("endTime") String endTime);

    /**
     * 主持人剧本详情
     * @param masterId
     * @param scriptId
     * @return
     */
    MasterScript masterScriptDetail(@Param("masterId") String masterId,
                                    @Param("scriptId") String scriptId);


    /**
     * 主持人财务列表
     * @param page
     * @param params
     * @return
     */
    Page<MasterFinanceListPageVo> masterFinancePage(Page page,@Param("params") MasterFinanceListSearchParams params);

    /**
     * 收支明细
     * @param page
     * @param params
     * @return
     */
    Page<FinanceDetailListPageVo> financeDetail(Page page,@Param("params") MasterFinanceListSearchParams params);

    /**
     * 剩余结算工资
     * @param masterId
     * @return
     */
    double leftSalary(@Param("masterId") String masterId);

    /**
     * 冻结总金额
     * @param masterId
     * @return
     */
    double totalFreezeAmount(@Param("masterId") String masterId);

    /**
     * 主持人结算工资
     * @param masterId
     * @return
     */
    boolean cleanMasterSalary(@Param("masterId") String masterId);

    /**
     * 提现审核通过
     * @param withdrawId
     * @return
     */
    boolean cleanMasterLeftAmount(@Param("withdrawId") String withdrawId);

    /**
     * 提现审核拒绝（冻结金额归0）
     * @param withdrawId
     * @return
     */
    boolean cleanMasterFreezeAmount(@Param("withdrawId") String withdrawId);

    /**
     * 提现申请列表
     * @param page
     * @param params
     * @return
     */
    Page<MasterWithdrawListPageVo> masterWithdrawList(Page page,@Param("params") MasterWithdrawSearchParams params);

    /**
     * 冻结收支金额
     * @param amount
     * @param financeId
     * @return
     */
    boolean changeMasterFinanceSingle(@Param("amount") Double amount,
                                      @Param("financeId") String financeId,
                                      @Param("withdrawId") String withdrawId);
}